<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
 	<link rel="stylesheet" href="../static/css/back/font.css">
 	<link rel="stylesheet" href="../static/css/back/role.css">
    <link rel="stylesheet" href="../static/css/back/xadmin.css">
    <script type="text/javascript" src="../static/js/jquery-2.1.1.min.js"></script>
    
    <script type="text/javascript" src="../static/js/back/xadmin.js"></script>
    <script type="text/javascript" src="../static/js/back/xcity.js"></script>
    <script type="text/javascript" src="../static/js/back/shop-audit.js"></script>
    <script type="text/javascript" src="../static/js/jquery.md5.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
.layui-upload-drag.pre{
	padding: 5px !important;
}
.layui-upload-drag.pre img{
	width:120px;
	height: 120px;
}
.layui-upload-drag+p{
	margin-top: 10px;
}
.layui-upload-list {
	text-align: -webkit-center;
}

.layui-upload {
	margin-left: 150px;
}
</style>
  </head>
  
  <body>
  <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="javascript:;">首页</a>
        <a href="javascript:;">门店管理</a>
        <a href="javascript:;"><cite>新增门店</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="iconfont icon-refresh right-top-ref" ></i></a>
    </div>
    <div class="x-body">
        <form class="layui-form" lay-filter="formAdd">
        <input type="hidden" id="paramKey" name="id" /> 
        <input type="hidden" id="shopUserId" name="shopUserId" /> 
    	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		  <legend>门店信息</legend>
		</fieldset>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>门店名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="username" name="shopTitle" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item" id="x-city">
            <label class="layui-form-label"><span class="x-red">*</span>门店区域</label>
            <input type="hidden"  id="addr-hide" />
            <div class="layui-input-inline">
              <select id="province" name="addressProvince" class="addr-c"  lay-filter="province">
                <option value="">请选择省</option>
              </select>
            </div>
            <div class="layui-input-inline">
              <select id="city" name="addressCity" class="addr-c"  lay-filter="city">
                <option value="">请选择市</option>
              </select>
            </div>
            <div class="layui-input-inline">
              <select id="area" name="addressArea" class="addr-c"  lay-filter="area">
                <option value="">请选择县/区</option>
              </select>
            </div>
          </div>
          <div class="layui-form-item">
              <label for="" class="layui-form-label">
                  <span class="x-red">*</span>详细地址
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="addressInfo" name="addressInfo" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
               <div class="layui-form-mid layui-word-aux  hide addr-info-tishi " style="color: red !important;">
				  填写的详细地址不在省市区范围内
				</div>
          </div>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  坐标定位 
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="addressLocation" readonly="readonly" name="addressLocation" required="" lay-verify=""
                  autocomplete="off" class="layui-input">
              </div>
<!--                <button class="layui-btn" lay-filter="" >地图定位</button> -->
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>门店类型
              </label>
              <div class="layui-input-inline">
                  <select id="shopType" name="shopType" class="valid" lay-verify="required">
                    <option value="">请选择</option>
                    <option value="1">美食</option>
                    <option value="2">超市</option>
                  </select>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  <span class="x-red">*</span>到期时间
              </label>
              <div class="layui-inline">
		      <div class="layui-input-inline">
		        <input type="text" name="serverEndTimeD" id="serverEndTime" readonly="readonly" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
		      </div>
		    </div>
          </div>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  入驻费用
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="shopInCharge" name="shopInCharge" required="" lay-verify="number|required"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid">元</div>
          </div>
          <div class="layui-form-item">
		          <div class="layui-inline">
		              <label for="phone" class="layui-form-label">
		                <span class="x-red">*</span> 门店logo
		              </label>
		              <input type="hidden" name="shopLogo" />
							<div class="layui-upload">
								<div class="layui-upload-list">
									<div class="layui-upload-drag shop-logo" id="shop-logo" >
										<i class="layui-icon"></i>
										<p>点击选择上传图片</p>
									</div>
									<div id="shop-logo-info">
										<div class="layui-upload-drag pre hide">
										    <img class="shop-logo" id="shop-logo-pre">
										  </div>
										 <p id="shop-logo-info-p"></p>
									</div>
<!-- 									<br><br> -->
<!-- 									<button type="button" class="layui-btn" id="shop-logo-btn" >上传图片</button> -->
								</div>
							</div>
						</div>
					  <div class="layui-inline">
						  <label for="phone" class="layui-form-label">
			                <span class="x-red">*</span> 营业执照
			              </label> 
			               <input type="hidden" name="shopLicense" />
			              <div class="layui-upload">
								<div class="layui-upload-list">
									<div class="layui-upload-drag shop-srct" id="shop-srct" >
										<i class="layui-icon"></i>
										<p>点击选择上传图片</p>
									</div>
									<div id="shop-logo-info">
										<div class="layui-upload-drag pre hide">
										    <img class="shop-srct" id="shop-srct-pre">
										  </div>
										 <p id="shop-srct-info-p"></p>
									</div>
<!-- 									<br><br> -->
<!-- 									<button type="button" class="layui-btn" id="shop-logo-btn" >上传图片</button> -->
								</div>
							</div>
		          </div>
          </div>
          <div class="layui-form-item">
		         <label for="phone" class="layui-form-label">
                </label>
                <div class="layui-inline layui-word-aux">
				  上传门店LOGO图片，支持jpg、png、jpeg格式的图片，建议上传800*800以上像素，大小在2M以内的正方形图片
				</div>
          </div>
	        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			  <legend>联系人信息</legend>
			</fieldset>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  <span class="x-red">*</span>姓名
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="userName" name="userName" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  <span class="x-red">*</span>联系方式
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="userContact" name="userContact" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
                <div class="layui-form-mid layui-word-aux">
				  该联系方式为默认门店电话
				</div>
          </div>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  <span class="x-red">*</span>身份证号
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="userIdCard" name="userIdCard" required="" lay-verify="required|identity"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
		          <div class="layui-inline">
		              <label for="phone" class="layui-form-label">
		                <span class="x-red">*</span> 手持身份证正面
		              </label>
		              <input type="hidden" name="userCardFront" />
							<div class="layui-upload">
								<div class="layui-upload-list">
									<div class="layui-upload-drag shop-idc" id="shop-idc" >
										<i class="layui-icon"></i>
										<p>点击选择上传图片</p>
									</div>
									<div id="shop-logo-info">
										<div class="layui-upload-drag pre hide">
										    <img class="shop-idc" id="shop-idc-pre">
										  </div>
										 <p id="shop-idc-info-p"></p>
									</div>
<!-- 									<br><br> -->
<!-- 									<button type="button" class="layui-btn" id="shop-logo-btn" >上传图片</button> -->
								</div>
							</div>
						</div>
					  <div class="layui-inline">
						  <label for="phone" class="layui-form-label">
			                <span class="x-red">*</span> 卫生许可证
			              </label> 
			              <input type="hidden" name="userCardBack" />
			              <div class="layui-upload">
								<div class="layui-upload-list">
									<div class="layui-upload-drag shop-idb" id="shop-idb" >
										<i class="layui-icon"></i>
										<p>点击选择上传图片</p>
									</div>
									<div id="shop-logo-info">
										<div class="layui-upload-drag pre hide">
										    <img class="shop-idb" id="shop-idb-pre">
										  </div>
										 <p id="shop-idb-info-p"></p>
									</div>
<!-- 									<br><br> -->
<!-- 									<button type="button" class="layui-btn" id="shop-logo-btn" >上传图片</button> -->
								</div>
							</div>
					  </div>
          </div>
          <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			  <legend>提现管理</legend>
			</fieldset>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  姓名
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="userWxName" name="userWxName" required="" lay-verify=""
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="userWx" class="layui-form-label">
                  微信
              </label>
              <div class="layui-input-inline">
                  <select id="userWx" name="userWx" class="valid">
                    <option value="">微信1</option>
                    <option value="">微信2</option>
                  </select>
              </div>
          </div>
          <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			  <legend>账号设置</legend>
		  </fieldset>
		  <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>登陆账号
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="userAccount" name="userAccount" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
          </div><div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>登陆密码
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="userPwd" name="userPwd" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
               <div class="layui-form-mid layui-word-aux edit-in hide">
			  		不填写则不修改
			   </div>
          </div>
            <div class="layui-form-item">
			    <label class="layui-form-label"></label>
			    <div class="layui-input-block">
			      <input type="radio" name="shopStatus" value="5" title="通过" checked=""  lay-filter='stat'>
			      <input type="radio" name="shopStatus" value="6" title="拒绝" lay-filter='stat'>
			    </div>
		  </div>
		  <div class="layui-form-item layui-form-text mark-info hide" >
              <label for="desc" class="layui-form-label">原因 </label>
              <div class="layui-input-block">
                  <textarea placeholder="请输入拒绝原因"  name="mark" class="layui-textarea"></textarea>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">确定</button>
          </div>
		   <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			  <legend>测试</legend>
		  </fieldset>
          <div class="layui-upload">
			  <button type="button" class="layui-btn" id="test1">上传图片</button>
			  <div class="layui-upload-list">
			    <img class="layui-upload-img" id="demo1">
			    <p id="demoText"></p>
			  </div>
			</div>   
      </form>
    </div>
    <script>
    	_showData=null;
    	__postions__ = {};
        
        
        layui.use(['form','layer','laydate'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer
          ,laydate = layui.laydate;
          //自定义验证规则
          form.verify({
            nikename: function(value){
              if(value.length < 5){
                return '昵称至少得5个字符啊';
              }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
          });
          laydate.render({
        	    elem: '#serverEndTime'
        	  });
          form.on('radio(stat)', function(data){
        	  console.log(data.elem); //得到radio原始DOM对象
        	  console.log(data.value); //被点击的radio的value值
        	  if(data.value == 6){
        		  $('.mark-info').show();
        	  }else{
        		  $('.mark-info').hide();
        	  }
        	}); 
          //监听提交
          form.on('submit(add)', function(data){
        	console.log(data);
        	if(data.field.userPwd){
      		  data.field.userPwd = $.md5(data.field.userPwd);
      	  	}
        	updateInfo(data.field);
            return false;
          });
          if(_showData){
	          console.log(_showData);
	          console.log(_showData.shopLogo);
	          console.log(_showData.shopLicense);
	          //
	          $('input[name="shopLogo"]').val(_showData.shopLogo);
	          $('#shop-logo').hide().parent().find('.pre').show().find('img').attr('src',_showData.shopLogo);
	          //
	          $('input[name="shopLicense"]').val(_showData.shopLicense);
	          $('#shop-srct').hide().parent().find('.pre').show().find('img').attr('src',_showData.shopLicense);
	          //
	          $('input[name="userCardFront"]').val(_showData.userCardFront);
	          $('#shop-idc').hide().parent().find('.pre').show().find('img').attr('src',_showData.userCardFront);
	          //
	          $('input[name="userCardBack"]').val(_showData.userCardBack);
	          $('#shop-idb').hide().parent().find('.pre').show().find('img').attr('src',_showData.userCardBack);
	          
	          $('#serverEndTime').val(formatDate( _showData.serverEndTime,"YY-MM-DD"));
	          console.log(_showData);
	          var t1=window.setInterval(showData, 200);
	          var ti_show_dd = 0;
				function showData(){
					ti_show_dd++;
			    	console.log(_showData);
					if (_showData) {
					    window.clearInterval(t1); 
						form.val("formAdd", _showData);
						form.render(); 
					}
					if(ti_show_dd>=40){
						window.clearInterval(t1); 
					}
				}
          }
        });
        
        layui.use('upload', function(){
        	  var $ = layui.jquery
        	  ,upload = layui.upload;
        	  //普通图片上传
        	  var uploadInst = upload.render({
        	    elem: '.shop-logo'
        	    ,url: '../sys/upload/uploadPics'
       	    	,size: 2048  //kb	
        	    ,before: function(obj){
        	      //预读本地文件示例，不支持ie8
        	      obj.preview(function(index, file, result){
	        	        $('#shop-logo-pre').attr('src', result).parent().show(); //图片链接（base64）
	        	        $('#shop-logo').hide(); 
        	      });
        	    }
        	    ,done: function(res){
        	      //如果上传失败
        	      if(res.resultCode == 1000){
        	    	  $("input[name='shopLogo']").val(res.returnObject);
        	      }else{
        	        return layer.msg('上传失败');
        	      }
        	      //上传成功
        	    }
        	    ,error: function(){
        	      var demoText = $('#shop-logo-info-p');
        	      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
        	      demoText.find('.demo-reload').on('click', function(){
        	        uploadInst.upload();
        	      });
        	    }
        	  });
        	  var uploadInst2 = upload.render({
        	    elem: '.shop-srct'
        	    ,url: '../sys/upload/uploadPics'
       	    	,size: 2048  //kb	
        	    ,before: function(obj){
        	      //预读本地文件示例，不支持ie8
        	      obj.preview(function(index, file, result){
	        	        $('#shop-srct-pre').attr('src', result).parent().show(); //图片链接（base64）
	        	        $('#shop-srct').hide(); 
        	      });
        	    }
        	    ,done: function(res){
        	      //如果上传失败
        	      if(res.resultCode == 1000){
          	    	  $("input[name='shopLicense']").val(res.returnObject);
          	      }else{
          	        return layer.msg('上传失败');
          	      }
        	      //上传成功
        	    }
        	    ,error: function(){
        	      var demoText = $('#shop-srct-info-p');
        	      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
        	      demoText.find('.demo-reload').on('click', function(){
        	    	  uploadInst2.upload();
        	      });
        	    }
        	  });
        	  var uploadInst3 = upload.render({
        	    elem: '.shop-idc'
        	    ,url: '../sys/upload/uploadPics'
        	    ,before: function(obj){
        	      //预读本地文件示例，不支持ie8
        	      obj.preview(function(index, file, result){
	        	        $('#shop-idc-pre').attr('src', result).parent().show(); //图片链接（base64）
	        	        $('#shop-idc').hide(); 
        	      });
        	    }
        	    ,done: function(res){
        	      //如果上传失败
        	      if(res.resultCode == 1000){
          	    	  $("input[name='userCardFront']").val(res.returnObject);
          	      }else{
          	        return layer.msg('上传失败');
          	      }
        	      //上传成功
        	    }
        	    ,error: function(){
        	      var demoText = $('#shop-idc-info-p');
        	      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
        	      demoText.find('.demo-reload').on('click', function(){
        	    	  uploadInst3.upload();
        	      });
        	    }
        	  });
        	  var uploadInst2 = upload.render({
        	    elem: '.shop-idb'
        	    ,url: '../sys/upload/uploadPics'
        	    ,before: function(obj){
        	      //预读本地文件示例，不支持ie8
        	      obj.preview(function(index, file, result){
	        	        $('#shop-idb-pre').attr('src', result).parent().show(); //图片链接（base64）
	        	        $('#shop-idb').hide(); 
        	      });
        	    }
        	    ,done: function(res){
        	      //如果上传失败
        	      if(res.resultCode == 1000){
          	    	  $("input[name='userCardBack']").val(res.returnObject);
          	      }else{
          	        return layer.msg('上传失败');
          	      }
        	      //上传成功
        	    }
        	    ,error: function(){
        	      var demoText = $('#shop-idb-info-p');
        	      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
        	      demoText.find('.demo-reload').on('click', function(){
        	    	  uploadInst4.upload();
        	      });
        	    }
        	  });
        });
        
        
        
        layui.use(['form','code'], function(){
            form = layui.form;
            layui.code();
            __postion__ = getCurrentPostionByIp();
            console.log(__postion__.province);
            var province =  __postion__.province;
			if(province.indexOf('内蒙古') >=0 ||province.indexOf('黑龙江') >=0){
				province =province.substring(0,3);
			}else{
				province =province.substring(0,2);
			}
            $('#x-city').xcity(province,__postions__.city);
          });
        
        function xcity_change(){
        	if($("#addressInfo").val()){
	        	var addrs = $("#province").val() + $('#city').val()+ $('#area').val();
		  		var local = getLocationByAddress(addrs +$("#addressInfo").val());
		  		console.log(local.level);
		  		if(local.level ==='省' || local.level==='市' || local.level === '区县'){
		  			$(".addr-info-tishi").show();
		  			$("#addressLocation").val("");
		  			return;
		  		}else{
		  			$(".addr-info-tishi").hide();
		  		$("#addressLocation").val(local.location);
		  		}
        	}
        }
    </script>

  </body>

</html>